package it.thalaz.thalaadm.action;


import it.thalaz.business.BusinessDelegate;
import it.thalaz.business.factory.thalaadm.UtentiFactory;
import it.thalaz.common.framework.action.IThalaCommand;
import it.thalaz.common.util.Constants;
import it.thalaz.dataaccess.dto.Utenti;
import it.thalaz.dataaccess.dto.UtentiDecorator;
import it.thalaz.dataaccess.dto.UtentiExample;
import it.thalaz.dataaccess.dto.UtentiExample.Criteria;
import it.thalaz.util.ThalazConstants;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class UtentiAction extends ActionSupport {

	private Utenti utente;



	public Utenti getUtente() {
		return utente;
	}

	public void setUtente(Utenti utente) {
		this.utente = utente;
	}



	public String execute() throws Exception{
		BusinessDelegate bDelegate = BusinessDelegate.getInstance();

		// Configurazione della classe
		UtentiDecorator form = null;
		form.setUtente(utente);
		Map session = ActionContext.getContext().getSession();
		
		IThalaCommand action = UtentiFactory.getCommand(form);
		action.checkUserPermissions((Utenti) session.get(Constants.SESSION_USER));
		return action.execute();
	}

	public String logout() throws Exception {

		Map session = ActionContext.getContext().getSession();
		session.remove("logged-in");
		return SUCCESS;
	}

}
